// pages/exam/examSetup/examSetup.js
var app = getApp();
var config = require('../../../config.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
  
    examThemeUrl:null,
    //是否展示 去报名
    isShowApply:true,
    examId:null

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //获取传入的考试id
    var id = options.examId;
    if(id==''||id==null){
      id='74'
    }
    this.setData({
      examId: id
    });
    // console.log("examId====="+id);
    // console.log("options=====" + JSON.stringify(options));
    this.initData(id);
  },



  //根据考试id获取考试信息 判断按钮可点击
  initData: function (examId){
    var that = this;
    console.log(app.globalData.openid)
    wx.request({
      url: config.getExamInfo,
      method: "POST",
      data: {
        examId: that.data.examId,
        openId: app.globalData.openid
      },
      success: function (ret) {
        var data = ret.data
        if (data.success == 0) {
          console.log(data);
          var examInfo = data.rows;
          if (examInfo){
            var showType = examInfo.showApply
            that.setData({
              isShowApply: showType == 1
            })
            var info = examInfo.exam;
            if(info){
              that.setData({
                examThemeUrl: info.themeUrl,
              })
            }

          }

        }
      }
    })


  }
  
})